<?php
declare (strict_types = 1);

namespace app\middleware;

use think\facade\Log;

class RequestLog
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
	    /**
	     * 记录访问信息
	     * -IP 请求方式 请求url
	     * -头部参数
	     * -请求参数
	     */
	    Log::record([
			'HOST'=> $request->ip() . ' ' . $request->method() . ' ' . $request->url(true),
			'HEADER'=>$request->header(),
			'PARAM'=>$request->param(),
	    ], 'Request');
	    return $next($request);
    }
}
